<?php
/**
 * Created by PhpStorm.
 * User: meng
 * Date: 2021/7/5
 * Time: 9:38 下午
 */

namespace app\lib\exception;
use \Exception;


class BaseException extends Exception
{
    public $code = 200;

    public $msg = '';

    public $errorCode = 2000;

    public $data = null;

    public function __construct ($message = [], $errorCode = null) {
        if (is_string($message)) {
            $this->msg = $message;
            if (!empty($errorCode)) {
                $this->errorCode = $errorCode;
            }
        } elseif (is_int($message)) {
            $this->errorCode = $message;
        } elseif (is_array($message)) {
            if (array_key_exists('code', $message)) {
                $this->code = $message['code'];
            }
            if (array_key_exists('msg', $message)) {
                $this->msg = $message['msg'];
            }
            if (array_key_exists('errorCode', $message)) {
                $this->errorCode = $message['errorCode'];
            }
            if (array_key_exists('data', $message)) {
                $this->data = $message['data'];
            }
        } else {
            return;
        }
        parent::__construct();
    }
}
